home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / DJLSR111.ZIP / libsrc / pc / src / screen.s < prev    next >
Text File  |  1993-07-04  |  5KB  |  256 lines

  1. /* This is file SCREEN.S */
  2. /*
  3. ** Copyright (C) 1993 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. **
  5. ** This file is distributed under the terms listed in the document
  6. ** "copying.dj", available from DJ Delorie at the address above.
  7. ** A copy of "copying.dj" should accompany this file; if not, a copy
  8. ** should be available from where this file was obtained.  This file
  9. ** may not be distributed without a verbatim copy of "copying.dj".
  10. **
  11. ** This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. **
  14. ** Modified by J. Alan Eldridge, Liberty Brokerage, 77 Water St, NYC 10005
  15. **
  16. ** added global char ScreenAttrib -- this is the attribute
  17. ** used by ScreenClear(): it defaults to 0x07 so as not to
  18. ** break existing code.
  19. **
  20. ** Modified by C. Sandmann (sandmann@clio.rice.edu) for DPMI support
  21. ** Combined SCREEN2.S and SCREEN.C into SCREEN.S
  22. */
  23.  
  24.     .data
  25.  
  26.     .globl    _ScreenAttrib
  27. _ScreenAttrib:
  28.     .byte 0x07
  29.  
  30.     .text
  31.  
  32.     .align 2
  33.     .globl    _ScreenSetCursor
  34.         /* row, col */
  35. _ScreenSetCursor:
  36.     pushl    %ebp
  37.     movl    %esp,%ebp
  38.     pushl    %ebx
  39.     pushl    %esi
  40.     pushl    %edi
  41.     movb    $0x02,%ah
  42.     movb    $0,%bh
  43.     movb    8(%ebp),%dh
  44.     movb    12(%ebp),%dl
  45.     int    $0x10
  46.     popl    %edi
  47.     popl    %esi
  48.     popl    %ebx
  49.     popl    %ebp
  50.     ret
  51.  
  52.     .align 2
  53.     .globl    _ScreenGetCursor
  54.          /* &row, &col */
  55. _ScreenGetCursor:
  56.     pushl    %ebp
  57.     movl    %esp,%ebp
  58.     pushl    %ebx
  59.     pushl    %esi
  60.     pushl    %edi
  61.     movb    $0x03,%ah
  62.     movb    $0,%bh
  63.     pushl    %ebp
  64.     int    $0x10
  65.     popl    %ebp
  66.     movl    8(%ebp),%esi
  67.     movzbl    %dh,%eax
  68.     movl    %eax,(%esi)
  69.     movl    12(%ebp),%esi
  70.     movzbl    %dl,%eax
  71.     movl    %eax,(%esi)
  72.     popl    %edi
  73.     popl    %esi
  74.     popl    %ebx
  75.     popl    %ebp
  76.     ret
  77.  
  78.     .align 2
  79.     .globl    _ScreenClear
  80. _ScreenClear:
  81.     pushl    %edi
  82.     call    _ScreenCols
  83.     movl    %eax,%ecx
  84.     call    _ScreenRows
  85.         /* ECX is total words to store */
  86.     imull    %eax,%ecx
  87.     movl    _ScreenPrimary,%eax
  88.     call    dosmemsetup
  89.     movl    %eax,%edi
  90.     push    %es
  91.     push    %gs
  92.     pop    %es
  93.     movb    $0x20,%al
  94.     movb    _ScreenAttrib,%ah
  95.     rep
  96.     stosw
  97.     pop    %es
  98.     popl    %edi
  99.     ret
  100.     
  101.     .align 2
  102.     .globl _ScreenRows
  103. _ScreenRows:
  104.     movl    $0x484,%eax
  105.     call    dosmemsetup
  106.     movzbl    %gs:(%eax),%eax
  107.     incl    %eax
  108.     ret
  109.  
  110.     .align 2
  111.     .globl _ScreenCols
  112. _ScreenCols:
  113.     movl    $0x44a,%eax
  114.     call    dosmemsetup
  115.     movzwl    %gs:(%eax),%eax
  116.     ret
  117.  
  118.     .align 2
  119.     .globl _ScreenMode
  120. _ScreenMode:
  121.     movl    $0x449,%eax
  122.     call    dosmemsetup
  123.     movzbl    %gs:(%eax),%eax
  124.     ret
  125.  
  126.     .align 2
  127.     .globl _ScreenPutChar
  128. _ScreenPutChar:
  129.         /* int ch, int attr, unsigned x, unsigned y */
  130. /*
  131.   if ( (x >= ScreenCols()) || (y >= ScreenRows())) return;
  132.   ch &= 0xff;
  133.   attr = (attr & 0xff) << 8;
  134.   *(unsigned short *)(ScreenPrimary+x+y*ScreenCols()) = ch | attr;
  135. */
  136.     call    _ScreenRows
  137.     cmpl    %eax,16(%esp)
  138.     jae    L1
  139.     call    _ScreenCols
  140.     cmpl    %eax,12(%esp)
  141.     jae    L1
  142.                 /* Out of range */
  143.     movl    %eax,%edx
  144.     imull    16(%esp),%edx
  145.     addl    12(%esp),%edx
  146.             /* EDX = x + y*ScreenCols */
  147.  
  148.     movb    4(%esp),%cl
  149.     movb    8(%esp),%ch
  150.  
  151.     movl    _ScreenPrimary,%eax
  152.     call    dosmemsetup
  153.     movw    %cx,%gs:(%eax,%edx,2)    
  154. L1:
  155.     ret    
  156.  
  157. /* A quick way to update the screen from a logical video buffer, used 
  158.    primarily for DPMI full screen management */
  159.     .align 2
  160.     .globl _ScreenUpdate
  161.         /* (void *)screenbuf */
  162. _ScreenUpdate:
  163.     call    _ScreenRows
  164.     movl    %eax,%ecx
  165.     call    _ScreenCols
  166.     imull    %eax,%ecx
  167.     sarl    $1,%ecx
  168.             /* Number of long words in screen */
  169.  
  170.     movl    _ScreenPrimary,%eax
  171.     call    dosmemsetup
  172.     movl    4(%esp),%edx
  173.         /* screenbuf */
  174.  
  175.     pushl    %esi
  176.     pushl    %edi
  177.     movl    %eax,%edi
  178.     movl    %edx,%esi
  179.     push    %es
  180.     push    %gs
  181.     pop    %es
  182.     rep
  183.     movsl
  184.                     /* move ECX bytes to Real area */
  185.     pop    %es
  186.     popl    %edi
  187.     popl    %esi
  188.     ret
  189.  
  190. /* A quick way to update a screen line from a logical video buffer, used 
  191.    primarily for DPMI full screen management */
  192.     .align 2
  193.     .globl _ScreenUpdateLine
  194.         /* (void *)screenline, int row */
  195. _ScreenUpdateLine:
  196.     call    _ScreenCols
  197.     movl    %eax,%ecx
  198.     sarl    $1,%ecx
  199.             /* Number of long words in screen line */
  200.     shll    $1,%eax
  201.     imull    8(%esp),%eax
  202.     addl    _ScreenPrimary,%eax
  203.     call    dosmemsetup
  204.     movl    4(%esp),%edx
  205.         /* screenbuf */
  206.  
  207.     pushl    %esi
  208.     pushl    %edi
  209.     movl    %eax,%edi
  210.     movl    %edx,%esi
  211.     push    %es
  212.     push    %gs
  213.     pop    %es
  214.     rep
  215.     movsl
  216.                     /* move ECX bytes to Real area */
  217.     pop    %es
  218.     popl    %edi
  219.     popl    %esi
  220.     ret
  221.  
  222.  
  223. /* A quick way to update the screen from a logical video buffer, used 
  224.    primarily for DPMI full screen management */
  225.     .align 2
  226.     .globl _ScreenRetrieve
  227.         /* (void *)screenbuf */
  228. _ScreenRetrieve:
  229.     call    _ScreenRows
  230.     movl    %eax,%ecx
  231.     call    _ScreenCols
  232.     imull    %eax,%ecx
  233.     sarl    $1,%ecx
  234.             /* Number of long words in screen */
  235.  
  236.     movl    _ScreenPrimary,%eax
  237.     call    dosmemsetup
  238.     movl    4(%esp),%edx
  239.         /* screenbuf */
  240.  
  241.     pushl    %esi
  242.     pushl    %edi
  243.     movl    %eax,%esi
  244.     movl    %edx,%edi
  245.     push    %ds
  246.     push    %gs
  247.     pop    %ds
  248.     rep
  249.     movsl
  250.                     /* move ECX bytes to Real area */
  251.     pop    %ds
  252.     popl    %edi
  253.     popl    %esi
  254.     ret
  255.  
  256.